package com.ayou.eggguard.farm.mapper;

import com.ayou.eggguard.farm.pojo.RelatedDrug;
import com.ayou.eggguard.farm.pojo.TreatMethod;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface TreatMethodMapper {
    List<TreatMethod> getMethods(String methodName);

    @Delete("delete from treatment_method where id=#{id}")
    void delete(Integer id);

    List<RelatedDrug> getDrugsByMethodName(String methodName);

    List<String> getMethodNameList(String methodName);

    @Select("select treatment_method.method_description from treatment_method where method_name=#{methodName}")
    String getMethodDescription(String methodName);

    @Delete("delete treatment_method,related_drug " +
            "from treatment_method " +
            "join related_drug on treatment_method.method_name=related_drug.method_name " +
            "where treatment_method.method_name=#{methodName}")
    void deleteMethod(String methodName);

    @Insert("insert into treatment_method(method_name,method_description) " +
            "values (#{methodName},#{methodDescription})")
    void add(String methodName, String methodDescription);

    long getTotalMethod(String methodName);

    @Select("select treatment_method.method_name from treatment_method")
    List<String> getMethodName();
}
